<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <SCript>
        let xhr = new XMLHttpRequest();
        // 0 已经创建了ajax对象，但是还没有对ajax对象进行配置；
        console.log('1', xhr.readyState);
        xhr.open('get', 'http://localhost:3000/readyState');
        // 1；已经对ajax对象进行配置，但是还没发送请求
        console.log('2', xhr.readyState);

        // 当ajax状态码发送变化的时候出发
        xhr.onreadystatechange = function () {
            console.log(xhr.readyState);
            if (xhr.readyState == 4) {
                console.log(xhr.responseText);
            }
        }

        // 发送请求
        xhr.send();

    </SCript>
</body>

</html>